<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:p="http://primefaces.org/ui">    

    <body>
        <ui:composition template="/pages/protected/templates/master.xhtml">           
            <ui:define  name="divTop">
                <h1>Destaques</h1>
            </ui:define>
            <ui:define  name="divMain">
                <h:form id="DestaquesForm" prependId="false" enctype="multipart/form-data">
                    <h:panelGrid id="painel" columns="3">

                        <h:outputText value="* #{bundle.destaquesDataInicial}" />
                        <p:calendar value="#{destaquesModel.destaques.dataincial}" showButtonPanel="true" id="dtaInicial">                                 
                        </p:calendar>
                        <p:message  for="dtaInicial" display="icon" /> 
                        <h:outputText value="* #{bundle.destaquesDataFinal}" />
                        <p:calendar value="#{destaquesModel.destaques.datafinal}"  showButtonPanel="true" id="dtaFinal">                            
                        </p:calendar>
                        <p:message  for="dtaFinal" display="icon" /> 
                        <h:outputText value="* #{bundle.destaquesLink}" />                

                        <p:fileUpload fileUploadListener="#{destaquesModel.processFileUpload}" 
                                      mode="advanced"   
                                      update="messages"  
                                      sizeLimit="100000"   
                                      allowTypes="/(\.|\/)(gif|jpe?g|png)$/"                                      
                                      />  
                        <p:growl id="messages" showDetail="true"/>  


                        <h:outputText value="* #{bundle.destaquesEstabelecimentos}" />                        
                        <p:selectOneMenu id="estab" value="#{destaquesModel.estabSelecionado}" effect="fade" 
                                         filter="true" filterMatchMode="startsWith">                              
                            <f:selectItems value="#{destaquesModel.estabData.buscarTodos()}" 
                                           var="e" itemLabel="#{e.nomefantasia}" itemValue="#{e.id}"/>  
                        </p:selectOneMenu>  
                        <p:message  for="estab" display="icon" />    

                        <p:commandButton value="#{bundle.create}" id="create"
                                         action="#{destaquesModel.salvar()}"
                                         update="painel,dest" />
                        <p:commandButton value="#{bundle.update}" id="update"
                                         actionListener="#{destaquesModel.atualizar()}"
                                         update="painel,dest" />                       

                        <p:commandButton value="#{bundle.cancel}" actionListener="#{destaquesModel.resetDestaque()}"
                                         update="painel,dest" id="cancel"/>
                    </h:panelGrid>
                    <br/>

                    <p:dataTable id="dest" var="destaque" value="#{destaquesModel.carregarTodosDestaques()}">  
                        <p:column headerText="ID">  
                            <h:outputText value="#{destaque.id}" />  
                        </p:column>  

                        <p:column headerText="Data Inicial">  
                            <h:outputText value="#{destaque.dataincial}" />  
                        </p:column>  

                        <p:column headerText="Data Final">  
                            <h:outputText value="#{destaque.datafinal}" />  
                        </p:column>

                        <p:column headerText="Link">  
                            <h:outputText value="#{destaque.link}" />  
                        </p:column>  
                        <p:column headerText="Estabelecimento">  
                            <h:outputText value="#{destaque.estabelecimentosId.id}" />  
                        </p:column>  

                    </p:dataTable>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
